<?php

// function smarty_block_stu($attr, $content, &$smarty)
// {   
//     // print_r($attr);exit;
//     if(empty($content))return '';
//     // print_r($attr);exit;
//     $sql = "select * from stu limit {$attr['row']}";
//     $rows = query($sql);
//     // print_r($rows);exit;
//     $return='';
//     foreach ($rows as $r) {
//         $tmp = $content;
//         // print_r($tmp);exit;
//         foreach ($r as $field => $value) {
//             $search = "[\$field['{$field}']]";
//             $tmp = str_replace($search, $value, $tmp);
//         }
//         $return.=$tmp
//     }
//     return $return;
// }

function smarty_block_stu($attr, $content, &$smarty)
{
    //让标签只执行一次
    if(empty($content))return '';

    $sql ="select * from stu limit {$attr['row']}";
    $rows = query($sql);

    $return ='';
    print_r($return);
    foreach($rows as $r)
    {
        $tmp = $content;

        foreach($r as $field=>$value)
        {
            $search = "[\$field['{$field}']]";
            $tmp= str_replace($search, $value, $tmp);
             // print_r($tmp);exit;
        }

        $return.=$tmp;
        
    }
    return $return;
}

?>
